package coml.jiyun.hp.sqlite;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class RlvAdapter extends RecyclerView.Adapter<RlvAdapter.ViewHoler> {

    private Context context;
    private ArrayList<String> mList;

    public RlvAdapter(Context context, ArrayList<String> mList) {
        this.context = context;
        this.mList = mList;
    }

    @NonNull
    @Override
    public ViewHoler onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View inflate = LayoutInflater.from(context).inflate(R.layout.layout_item, parent, false);
        return new ViewHoler(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHoler holder, int position) {
        holder.mTv.setText(mList.get(position));
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class ViewHoler extends RecyclerView.ViewHolder {

        ImageView mImg;
        TextView mTv;

        public ViewHoler(@NonNull View itemView) {
            super(itemView);

            mImg = itemView.findViewById(R.id.item_img);
            mTv = itemView.findViewById(R.id.item_tv);

        }
    }
}
